package com.gaodun.hk.web;

import com.gaodun.hk.common.response.BasicResponse;
import com.gaodun.hk.domain.entity.SmsSendRecord;
import com.gaodun.hk.integration.LuffyClient;
import com.gaodun.hk.service.SmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author fengyamin
 * @date 2021/03/02
 **/
@Slf4j
@RestController
@RequestMapping("/api/v1/sms")
@Api(tags = {"测试"})
public class TestEndpoint {

    @Resource
    private SmsService smsService;

    @Resource
    private LuffyClient luffyClient;

    @PostMapping("/saveSmsMsgRecord")
    @ApiOperation(value = "发送记录", notes = "发送记录")
    public Integer saveSmsMsgRecord(@RequestBody SmsSendRecord smsSendRecord) {
        return smsService.saveSmsMsgRecord(smsSendRecord);
    }

    @GetMapping("/query")
    @ApiOperation(value = "查询", notes = "查询")
    public SmsSendRecord query(Integer id) {
        //无包装，无数据时前端是document类型显示
        return smsService.query(id);
    }

    @GetMapping("/getAccessToken")
    @ApiOperation(value = "查询token", notes = "查询token")
    public BasicResponse getAccessToken(String appid) {
        //无包装，无数据时前端是document类型显示
        return luffyClient.getAccessToken(appid);
    }

}
